        var listStore = new Ext.data.JsonStore({
			url: '/weihe/getALLList_shoppingList',
			root: 'datas',
			fields : [{
			        	   name:'listId',mapping:'id'
			          },{
        				   name:'listCode',mapping:'code'
        			  },{
        				   name:'listListNum',mapping:'listNum'
        			  },{
        				   name:'listDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
        			  },{
        				   name:'listTotal',mapping:'total'
        			  },{
        				   name:'listType',mapping:'type'
        			  },{
        				   name:'listState',mapping:'state'
        			  },{
        				   name:'listRemark',mapping:'remark'
        			  }],
			listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_shoppingList',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	
        
        var shopStore = new Ext.data.JsonStore({
			url: '/weihe/getSLCargo_shoppingList',
			root: 'datas',
			fields : [{
			        	   name:'shopId',mapping:'id'
			          },{
			        	   name:'shopAmount',mapping:'amount' 
			          },{
        				   name:'shopPrice',mapping:'price'
        			  },{
        				   name:'shopRemark',mapping:'remark'
        			  },{
        				   name:'shopSum',mapping:'sum'
        			  },{
        				   name:'shopState',mapping:'state'
        			  },{
        				   name:'shopOrigin',mapping:'cargo', convert:function(v){ 
														return v ? v.origin : undefined;}
        			  },{
						   name:'shopCode',mapping:'cargo', convert:function(v){ 
														return v ? v.code : undefined;}
			          },{
			        	   name:'shopName',mapping:'cargo', convert:function(v){ 
														return v ? v.name : undefined;}
			          },{
			        	   name:'shopSpecs',mapping:'cargo', convert:function(v){ 
			        	  								return v ? v.specs : undefined;}
			          },{
			        	   name:'shopUnit',mapping:'cargo', convert:function(v){ 
			        	  								return v ? v.unit : undefined;}
			          }],
			  listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_shoppingList',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    
    	

 listSL = function(){
     
 	var tmp='';
	 return{  
        	  
		 listGrid : function(){
        		  
        			var pageToolBar = new Ext.PagingToolbar({
        				pageSize : 5,
        				store : listStore,
        				displayInfo : true,
        				displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
        			    emptyMsg : "没有记录显示!",
        			    firstText : '首页',
        			    prevText : '上一页',
        			    nextText : '下一页',
        			    lastText : '尾页',
        			    beforePageText : '第',
        			    afterPageText : '页,共{0}页'
        			});


        			var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
        			
        			
        			 var stateComboData = new Ext.data.SimpleStore({
												fields : ['text'],
												data : [['新建'],['采购申请'],['确认申请'],['正在采购'],['已完结']]
												});
        			
        var queryForm = new Ext.form.FormPanel({
			baseCls:"x-plain",
			frame : true,
			width : 300,
			autoScroll : true,
			labelAlign : 'right',
			labelWidth : 85,
			defaultType : 'textfield',
				defaults : {
				width : 200
			},
			items : [{
					  fieldLabel: "订单号",
      	    		  name: "shoppingList.code"
			 	  },{
					  fieldLabel: "采购单号",
      	    		  name: "shoppingList.listNum"
			 	  },{
					  fieldLabel : '采购单状态',
				      name : 'shoppingList.state',
					  xtype : 'combo',
					  store : stateComboData,
				      emptyText : '请选择',
					  mode : 'local',
					  triggerAction : 'all',
					  editable: false,
				      displayField : 'text'
				   },{
            		  xtype: 'datefield',
                      fieldLabel: "开始日期", //第三行，出生日期 
                      format : 'Y-m-d',
            		  name: "shoppingList.date"
				   },{
            		  xtype: 'datefield',
                      fieldLabel: "结束日期", //第三行，出生日期 
                      format : 'Y-m-d',
            		  name: "shoppingList.endDate"
				   }],
			buttons:[{
        		 text:'确认',
             	 handler:function(){
             	 	var code = queryForm.form.findField('shoppingList.code').getValue()
             	 	var listNum = queryForm.form.findField('shoppingList.listNum').getValue()
             	 	var state = queryForm.form.findField('shoppingList.state').getValue()
             	 	var date = queryForm.form.findField('shoppingList.date').getValue()
             	 	var endDate = queryForm.form.findField('shoppingList.endDate').getValue()
				 Ext.getCmp("listGrid").getStore().baseParams = {'flag': true,'shoppingList.code':code,
					 													  'shoppingList.listNum':listNum,
					 													  'shoppingList.state':state,
					 													  'shoppingList.date':date,
					 													  'shoppingList.endDate':endDate};
				 Ext.getCmp("listGrid").getStore().load({params : {start : 0, limit : 5}});
				 queryForm.form.reset();
                 infoWin.hide();
              	
              	}
              },{
                 text:'取消',
                 handler:function(){
                 	queryForm.form.reset();
                 	infoWin.hide();
                 }
              }]   
        });
        

       
       var infoWin = new Ext.Window({    
        title:'采购单查询',    
        width:330,    
        height:230,
        resizable: false,
        closeAction:"hide",
        plain:true,    
        items:[queryForm] 
        
    });    


        
        			   
        		   var listGrid = new Ext.grid.GridPanel({
        			   id:'listGrid',
        			   title: '采购单信息表',
        			   region: 'north',
        			   height: 220,
        			   autoWidth: true,
        			   minColumnWidth : 50,
        			   loadMask : {msg:'正在加载数据，请稍侯...'}, // 单击分页时显示,为true显示'Loading...'
        			   store : listStore,
        			   tbar:[{
	   						text:"输入查询条件",
								handler:function(){
										infoWin.show();
								}
	   					},"-",{
	   						text:"查看全部",
								handler:function(){
									Ext.getCmp("listGrid").getStore().baseParams = {'flag': false};
									Ext.getCmp("listGrid").getStore().load({params : {start : 0, limit : 5}});
								}
	   					},"-"],
        			   columns: [
        			             {header : '订单号', dataIndex : 'listCode'},
        			             {header : '采购单号', dataIndex : 'listListNum'},
        			             {header : '发送日期', dataIndex : 'listDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
        			             {header : '类型', dataIndex : 'listType', menuDisabled : true},
        			             {header : '总价', dataIndex : 'listTotal', menuDisabled : true},
        			             {header : '状态', dataIndex : 'listState', menuDisabled : true},
        			             {header : '回执', dataIndex : 'listRemark', menuDisabled : true}
        			             
        			             ],
        	           sm : rowSelectionModel,
        	           listeners :{ 
        				   'rowclick':function(grid, rowIndex, event) {
        				   		var record = grid.getStore().getAt(rowIndex);
        				   		tmp  = record.id;
        				   		
								Ext.getCmp("shopGrid").getStore().baseParams = {'shoppingList.id': record.id};
								Ext.getCmp("shopGrid").getStore().load({params : {start : 0, limit : 8}});
        			   		}
        			   },
        			  bbar : pageToolBar
        	});
        			return listGrid;
        		},
        		 grid : function(){
        			 


        			var pageToolBar = new Ext.PagingToolbar({
        				pageSize : 8,
        				store : shopStore,
        				displayInfo : true,
        				displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
        			    emptyMsg : "没有记录显示!",
        			    firstText : '首页',
        			    prevText : '上一页',
        			    nextText : '下一页',
        			    lastText : '尾页',
        			    beforePageText : '第',
        			    afterPageText : '页,共{0}页'
        			   


        			});


        			var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
        			
        			   
        		   var grid = new Ext.grid.GridPanel({
        			   id:'shopGrid',
        			   title : '货物信息表',
        			   region : 'center',
        			   minColumnWidth : 50,
        			   loadMask : {msg:'正在加载数据，请稍侯...'}, // 单击分页时显示,为true显示'Loading...'
        			   store : shopStore,
        			   columns: [
        			             {header : '产品编号', dataIndex : 'shopCode', menuDisabled : true},
        			             {header : '产品名称', dataIndex : 'shopName'},
        			             {header : '规格型号', dataIndex : 'shopSpecs', menuDisabled : true},
        			             {header : '单位', dataIndex : 'shopUnit', menuDisabled : true},
        			             {header : '单价', dataIndex : 'shopPrice',sortable : true},
        			             {header : '数量', dataIndex : 'shopAmount', menuDisabled : true},
        			             {header : '金额', dataIndex : 'shopSum', menuDisabled : true},
        			             {header : '状态', dataIndex : 'shopState', menuDisabled : true},
        			             {header : '备注', dataIndex : 'shopRemark', menuDisabled : true}
        	        ],
        	           sm : rowSelectionModel,
        			   viewConfig : {
        			     forceFit : false
        			  },
        			  bbar : pageToolBar
        	});
        			return grid;
        		}
        		
        	  }
        	}();




